package com.web.servlet.dao.impl;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sun.tools.javac.util.List;
import com.web.servlet.bean.GameInfo;
import com.web.servlet.bean.GameServerInfo;
import com.web.servlet.dao.GameServerInfoDao;
import com.web.servlet.db.StrategyBaseDao;

public class GameServerInfoDaoImpl extends StrategyBaseDao implements GameServerInfoDao {
	public static final Logger log = LoggerFactory.getLogger(GameServerInfoDaoImpl.class);
	@Override
	public ArrayList<GameServerInfo> getGameServerInfoAll() {
		ArrayList<GameServerInfo> infoList = new ArrayList<GameServerInfo>();
		String sqlText ="SELECT * FROM g_serverlist ";
		PreparedStatement pstmt = execQuery(sqlText);
		ResultSet rs = null;
		if (pstmt != null) {
			try {
				rs = pstmt.executeQuery();
				while (rs.next()) {
					GameServerInfo info = new GameServerInfo();
					info.setId(rs.getInt("id"));
					info.setGame_id(rs.getInt("game_id"));
					info.setName(rs.getString("name"));
					info.setGame_url(rs.getString("game_url"));
					info.setGameVersion(rs.getString("gameVersion"));
					info.setGame_icon(rs.getString("game_icon"));
					info.setGame_downurl(rs.getString("game_downurl"));
					info.setGameicon_downurl(rs.getString("gameicon_downurl"));
					info.setWeb_url(rs.getString("web_url"));
					info.setPar1(rs.getString("par1"));
					info.setGameserver_status(rs.getInt("gameserver_status"));
					infoList.add(info);
				}
			} catch (Exception e) {
				log.error("获取Site用户列表异常", e);
			} finally {
				closeConn(pstmt, rs);
			}
		}
		return infoList;
	
	}

	@Override
	public ArrayList<GameInfo> getGameInfoAll() {
		ArrayList<GameInfo> infoList = new ArrayList<GameInfo>();
		String sqlText ="SELECT * FROM g_versioninfo ";
		PreparedStatement pstmt = execQuery(sqlText);
		ResultSet rs = null;
		if (pstmt != null) {
			try {
				rs = pstmt.executeQuery();
				while (rs.next()) {
					GameInfo info = new GameInfo();
					info.setId(rs.getInt("id"));
					info.setGame_id(rs.getInt("game_id"));
					info.setName(rs.getString("name"));
					info.setGame_url(rs.getString("game_url"));
					info.setGame_version(rs.getString("game_version"));
					info.setAndroid_version(rs.getString("android_version"));
					info.setAndroid_url(rs.getString("android_url"));
					info.setIos_version(rs.getString("ios_version"));
					info.setIos_url(rs.getString("ios_url"));
					info.setIcon_version(rs.getString("icon_version"));
					info.setIcon_url(rs.getString("icon_url"));
					info.setGame_status(rs.getInt("game_status"));
					infoList.add(info);
				}
			} catch (Exception e) {
				log.error("获取Site用户列表异常", e);
			} finally {
				closeConn(pstmt, rs);
			}
		}
		return infoList;
	
	}

}
